
include std/unittest.e
include qt/trigmath.e as trig
include std/math.e


test_equal("1 = min({1, 3, 4})", 1, trig:min({1, 3, 4}))
test_equal("4 = max({1, 3, 4})", 4, trig:max({1, 3, 4}))
test_not_equal("test bad 3 != mod(2,6)", 3, trig:mod(2,6))
test_equal("0 = mod(2,6)", 0, trig:mod(2,6))
test_equal("0 = mod(6,2)", 0, trig:mod(6,2))

--I think iits 0,0,1 so fib 3 shoul d be 1? better get it right in the tests first.
test_equal("0 = fib(0)", 0, trig:fib(0))
test_equal("1 = fib(1)", 1, trig:fib(1))
test_equal("2 = fib(3)", 2, trig:fib(3))
test_equal("5 = fib(5)", 5, trig:fib(5))

test_equal("114.591559026? = rad2deg(2.0)", 114.59156, rad2deg(2.0))
test_equal("720? = fact(6)", 720, trig:fact(6))

--result from drmath dissagree with nPr in permcomb. nPr works w/gsl though
test_equal("perm_n_by_r",5040 ,trig:perm_n_by_r(10,4))

 --getting rouning error
--~ test_equal("d2r(2.0)", 0.0349065850399, trig:d2r(2.0))
test_equal("tae d2r(2.0)", 0.0349065850399, trig:d2r(2.0) ) --Atom,13) --14 fails
test_equal("d2r(2.0)", 2.0, trig:d2r(trig:r2d(2.0)))

--~ test_equal("Dist(2, 2, 1, 1 )", 1.41421356237, trig:Dist(2, 2, 1, 1 )) -- fails
test_equal("tae Dist(2, 2, 1, 1 )", 1.41421356237, trig:Dist(2, 2, 1, 1 ) ) --Atom,11)

test_equal("seqabs",{1, 3, 4}, trig:seqabs({1, 3, 4}))
test_equal("seqabs-",{1, 3, 4}, trig:seqabs({1, -3, 4}))
test_equal("seqmin", 2, trig:seqmin({1, -3, 4}))
test_equal("seqmax",3, trig:seqmax({1, -3, 4}))

test_equal("fabs",12, trig:fabs(12.0) ) --Atom,13)
test_equal("abs",2, trig:abs(2.0))

--~ test_equal("gcd",12, trig:gcd(integer a, integer b)))
--~ test_equal("deg",12, trig:deg(2.0),13)
--~ test_equal("rad_deg",12, trig:rad_deg(2.0),13)
--~ test_equal("log_10",12, trig:log_10(2.0),13)
--~ test_equal("frac",12, trig:frac(2.0),13)

test_equal("dec_frac",{1,4}, trig:dec_frac(0.25))
test_equal("dec_frac",{5,8}, trig:dec_frac(0.625))
--~ test_equal("ceiling",12, trig:ceiling(atom x1)))
--~ test_equal("exp",12, trig:exp(2.0),13)



--~ 259:global procedure pascal_triangle(atom rows)
--~ test_equal("sinh",12, trig:sinh(2.0),13)
--~ test_equal("cosh",12, trig:cosh(2.0),13)
--~ test_equal("tanh",12, trig:tanh(2.0),13)


--~ test_equal("matrix_add",12, trig:matrix_add(sequence a,sequence b,atom row,atom column,atom s)))
--~ test_equal("matrix_mult",12, trig:matrix_mult(sequence a,sequence b,atom row,atom column)))

--~ test_equal("km2mi",12, trig:km2mi(atom mi)))
--~ test_equal("mi2km",12, trig:mi2km(atom km)))

test_equal("SQ",4, trig:SQ(2.0))
test_equal("CB",8, trig:CUBE(2.0))
test_equal("CB",8.0, trig:CUBE(2.0))

test_equal("cordRH",2.0, trig:cordRH(1, 1  ) ) --Atom,12)
test_equal("cordRANG",14.1421356237, trig:cordRANG(10, 90.0) ) --Atom,10)

test_equal("RCircum", 0.318309886184, trig:RCircum(1.0) ) --Atom,12)--?
test_equal("CircumR",6.28318530718, trig:CircumR(1.0 ) ) --Atom,12)
test_equal("CircumD",3.14159265359, trig:CircumD(1.0) ) --Atom,12)
test_equal("dms2deg",75.0786111111, trig:dms2deg({75, 4, 43}) ) --Atom,10)

test_equal("AreaCircle",12.5663706144, trig:AreaCircle(2) ) --Atom,10)
test_equal("VolSphere",33.5103216383, trig:VolSphere(2) ) --Atom,10)
test_equal("AreaSphere",50.2654824574, trig:AreaSphere(2) ) --Atom,10)
test_equal("VolCube",8.0, trig:VolCube(2) ) --Atom,12)
test_equal("AreaCube",24.0, trig:AreaCube(2) ) --Atom,12)
test_equal("AreaRect", 4.0, trig:AreaRect(2.0, 2.0 ) ) --Atom,12)
test_equal("VolBox",8.0, trig:VolBox(2, 2, 2.0) ) --Atom,12)
test_equal("AreaBox",24.0, trig:AreaBox(2, 2, 2.0) ) --Atom,12)
test_equal("VolCyl",25.1327412287, trig:VolCyl(2, 2.0) ) --Atom,10)
test_equal("AreaCyl",25.1327412287, trig:AreaCyl(2, 2.0) ) --Atom,10)
test_equal("inscribSQ",2.8284, trig:inscribSQ( 2.0) ) --Atom,10)
test_equal("equalSQ",3.5448, trig:equalSQ(2.0) ) --Atom,10)
test_equal("AreatriAB",2.0, trig:AreatriAB(2, 2.0) ) --Atom,10)
test_equal("ABCo2",3.0, trig:ABCo2(2, 2, 2.0) ) --Atom,12)
test_equal("AreatriABE",0.069798993405, trig:AreatriABE(2, 2, 2.0) ) --Atom,12)
test_equal("AreatriABC",1.73205080757, trig:AreatriABC(2, 2, 2.0) ) --Atom,10)
  --~ failed: AreatriABE. expected: 0.0697989934 but got: 0.06980962575

--~ test_equal("quat1x",12, trig:quat1x(atom x )))
--~ test_equal("quat2x",12, trig:quat2x(atom x )))
--~ test_equal("quat3x",12, trig:quat3x(atom x )))
--~ test_equal("quat4x",12, trig:quat4x(atom x )))
--~ test_equal("quat1y",12, trig:quat1y(atom y )))
--~ test_equal("quat2y",12, trig:quat2y(atom y )))
--~ test_equal("quat3y",12, trig:quat3y(atom y )))
--~ test_equal("quat4y",12, trig:quat4y(atom y )))

--~ test_equal("sqrtPY",12, trig:sqrtPY(atom a, atom b )))
--~ test_equal("oAof90BC",12, trig:oAof90BC(atom b, atom c )))

--~ test_equal("Aof90BC",12, trig:Aof90BC(atom b, atom c )))
--~ test_equal("Aof90BD",12, trig:Aof90BD(atom b, atom d )))
--~ test_equal("Aof90BE",12, trig:Aof90BE(atom b, atom e )))
--~ test_equal("Aof90CD",12, trig:Aof90CD(atom c, atom d )))
--~ test_equal("Aof90CE",12, trig:Aof90CE(atom c, atom e )))
--~ test_equal("AofFBD",12, trig:AofFBD(atom F, atom b, atom D )))
--~ test_equal("Bof90AC",12, trig:Bof90AC(atom a, atom c )))
--~ test_equal("Bof90AE",12, trig:Bof90AE(atom a, atom e )))
--~ test_equal("Bof90AD",12, trig:Bof90AD(atom a, atom d )))
--~ test_equal("Bof90CD",12, trig:Bof90CD(atom c, atom d )))
--~ test_equal("Bof90CE",12, trig:Bof90CE(atom c, atom e )))
--~ test_equal("BofFAD",12, trig:BofFAD(atom F, atom a, atom d )))
--~ test_equal("Cof90AB",12, trig:Cof90AB(atom a, atom b )))
--~ test_equal("Cof90AD",12, trig:Cof90AD(atom a, atom d )))
--~ test_equal("Cof90AE",12, trig:Cof90AE(atom a, atom e )))
--~ test_equal("Cof90BD",12, trig:Cof90BD(atom b, atom d )))
--~ test_equal("Cof90BE",12, trig:Cof90BE(atom b, atom e )))
--~ test_equal("CofABE",12, trig:CofABE(atom a, atom b, atom e )))
--~ test_equal("Dof90AB",12, trig:Dof90AB(atom a, atom b )))
--~ test_equal("Dof90BC",12, trig:Dof90BC(atom b, atom c )))
--~ test_equal("Dof90E",12, trig:Dof90E(atom E )))
--~ test_equal("DofFE",12, trig:DofFE(atom F, atom e )))
--~ test_equal("DofACE",12, trig:DofACE(atom a, atom c, atom e )))
--~ test_equal("Eof90AC",12, trig:Eof90AC(atom a, atom c )))
--~ test_equal("Eof90AB",12, trig:Eof90AB(atom a, atom b )))
--~ test_equal("Eof90D",12, trig:Eof90D(atom D )))
--~ test_equal("EofFD",12, trig:EofFD(atom F, atom D )))
--~ test_equal("EofACD",12, trig:EofACD(atom a, atom c, atom d )))
--~ test_equal("FofABD",12, trig:FofABD(atom a, atom b, atom d )))
--~ test_equal("FofED",12, trig:FofED(atom E, atom d )))
--~ test_equal("starret",12, trig:starret(object kw) --**))



--~ exitpause(sprintf("done %d%% passed\n", {(testsPassed / testCount) * 100})) 

test_report()
